package com.jash.labor.service;

import com.baomidou.mybatisplus.core.conditions.query.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jash.labor.context.Result;
import com.jash.labor.entity.FirstParty;
import com.jash.labor.mapper.FirstPartyMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.HashMap;


@Service
public class FirstPartyService {
    @Resource
    private FirstPartyMapper firstPartyMapper;

    public Object add(FirstParty firstParty){
        firstParty.setCreatetime(new Timestamp(System.currentTimeMillis()));
        firstPartyMapper.insert(firstParty);
        //增删改操作 返回
        return Result.SUCCESS;
    }
    public Object edit(FirstParty firstParty){
        firstPartyMapper.updateById(firstParty);
        //增删改操作 返回
        return Result.SUCCESS;
    }

    public Object queryListPage(Integer companyId, Integer pageNo, Integer pageSize) {
        Page<FirstParty> page = new Page(pageNo,pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("company_id",companyId);
        IPage iPage = firstPartyMapper.selectPage(page,wrapper);
        return new Result<>(iPage);
    }
}
